<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>TRSS Akasha Terminal Plugin - 管理界面</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/chart.js@3.9.1/dist/chart.min.js"></script>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');
        
        * {
            font-family: 'Noto Sans SC', sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
            background-attachment: fixed;
            position: relative;
            overflow-x: hidden;
        }
        
        body::before {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-image: url('https://img.paulzzh.com/touhou/random');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            opacity: 0.3;
            z-index: -1;
            transition: opacity 0.5s ease;
        }
        
        .background-loading {
            opacity: 0.1 !important;
        }
        
        .sidebar {
            min-height: 100vh;
            background: rgba(243, 153, 183, 0.3);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 0 20px 20px 0;
            box-shadow: 0 8px 32px rgba(255, 107, 157, 0.3),
                        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
        }
        
        .nav-link {
            color: rgba(255, 255, 255, 0.9);
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            border-radius: 15px;
            margin: 5px 0;
            padding: 12px 20px;
            position: relative;
            overflow: hidden;
        }
        
        .nav-link::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
            transition: left 0.5s;
        }
        
        .nav-link:hover::before {
            left: 100%;
        }
        
        .nav-link:hover, .nav-link.active {
            color: white;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
            transform: translateX(5px);
            box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
        }
        
        .card {
            border: none;
            border-radius: 20px;
            background: rgba(255, 255, 255, 0.15);
            backdrop-filter: blur(15px);
            -webkit-backdrop-filter: blur(15px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            box-shadow: 0 8px 32px rgba(255, 107, 157, 0.1), 
                        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            overflow: hidden;
            position: relative;
        }
        
        .card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 3px;
            background: linear-gradient(90deg, #ff6b9d, #c44569, #ff6b9d);
            background-size: 200% 100%;
            animation: shimmer 2s infinite;
        }
        
        @keyframes shimmer {
            0% { background-position: -200% 0; }
            100% { background-position: 200% 0; }
        }
        
        .card:hover {
            transform: translateY(-8px) scale(1.02);
            background: rgba(255, 255, 255, 0.25);
            box-shadow: 0 15px 40px rgba(255, 107, 157, 0.2),
                        0 0 0 1px rgba(255, 255, 255, 0.2) inset;
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
        }
        
        .btn {
            border-radius: 25px;
            padding: 10px 25px;
            font-weight: 500;
            transition: all 0.3s;
            position: relative;
            overflow: hidden;
        }
        
        .btn-primary {
            background: rgba(255, 107, 157, 0.3);
            backdrop-filter: blur(15px);
            -webkit-backdrop-filter: blur(15px);
            border: 1px solid rgba(255, 255, 255, 0.3);
            color: white;
            box-shadow: 0 4px 15px rgba(255, 107, 157, 0.2),
                        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
        }
        
        .btn-primary:hover {
            background: rgba(255, 107, 157, 0.5);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(255, 107, 157, 0.4),
                        0 0 0 1px rgba(255, 255, 255, 0.2) inset;
        }
        
        .status-indicator {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 8px;
            animation: pulse 2s infinite;
        }
        
        @keyframes pulse {
            0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
            70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
            100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
        }
        
        .status-connected {
            background: linear-gradient(135deg, #28a745, #20c997);
        }
        
        .status-disconnected {
            background: linear-gradient(135deg, #dc3545, #fd7e14);
            animation-name: pulse-red;
        }
        
        @keyframes pulse-red {
            0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
            70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
            100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
        }
        
        .content-section {
            display: none;
            animation: fadeInUp 0.5s ease-out;
        }
        
        .content-section.active {
            display: block;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .table-responsive {
            max-height: 400px;
            overflow-y: auto;
            border-radius: 15px;
        }
        
        .table {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 15px;
        }
        
        .json-editor {
            font-family: 'Courier New', monospace;
            font-size: 14px;
            border-radius: 15px;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .stats-card {
            background: rgba(255, 107, 157, 0.2);
            backdrop-filter: blur(15px);
            -webkit-backdrop-filter: blur(15px);
            border: 1px solid rgba(255, 255, 255, 0.3);
            color: white;
            border-radius: 20px;
            box-shadow: 0 8px 32px rgba(255, 107, 157, 0.2),
                        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
        }
        
        .loading {
            display: none;
        }
        
        .loading.show {
            display: inline-block;
        }
        
        .form-control, .form-select {
            border-radius: 15px;
            border: 1px solid rgba(255, 255, 255, 0.3);
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            color: #333;
            transition: all 0.3s;
        }
        
        .form-control:focus, .form-select:focus {
            border-color: rgba(255, 107, 157, 0.5);
            background: rgba(255, 255, 255, 0.2);
            box-shadow: 0 0 0 0.2rem rgba(255, 107, 157, 0.25),
                        0 0 0 1px rgba(255, 255, 255, 0.2) inset;
            backdrop-filter: blur(15px);
            -webkit-backdrop-filter: blur(15px);
        }
        
        .floating-hearts {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: -1;
        }
        
        .heart {
            position: absolute;
            color: rgba(255, 107, 157, 0.3);
            font-size: 20px;
            animation: float 6s infinite ease-in-out;
        }
        
        @keyframes float {
            0% {
                transform: translateY(100vh) rotate(0deg);
                opacity: 0;
            }
            10% {
                opacity: 1;
            }
            90% {
                opacity: 1;
            }
            100% {
                transform: translateY(-100px) rotate(360deg);
                opacity: 0;
            }
        }
        
        .sleep-mode {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 9999;
        }
        
        .sleep-content {
            text-align: center;
            color: white;
            animation: breathe 2s infinite;
        }
        
        @keyframes breathe {
            0%, 100% { opacity: 0.7; }
            50% { opacity: 1; }
        }
        
        .ranking-list {
            max-height: 400px;
            overflow-y: auto;
        }
        
        .ranking-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 12px;
            margin-bottom: 5px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            border-left: 4px solid;
        }
        
        .ranking-item:nth-child(1) {
            border-left-color: #ffd700;
            background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.1));
        }
        
        .ranking-item:nth-child(2) {
            border-left-color: #c0c0c0;
            background: linear-gradient(135deg, rgba(192, 192, 192, 0.2), rgba(192, 192, 192, 0.1));
        }
        
        .ranking-item:nth-child(3) {
            border-left-color: #cd7f32;
            background: linear-gradient(135deg, rgba(205, 127, 50, 0.2), rgba(205, 127, 50, 0.1));
        }
        
        .ranking-item:nth-child(n+4) {
            border-left-color: #6c757d;
        }
        
        .ranking-rank {
            font-weight: bold;
            min-width: 30px;
        }
        
        .ranking-id {
            flex: 1;
            margin: 0 10px;
            font-family: monospace;
        }
        
        .ranking-count {
            font-weight: bold;
            color: #007bff;
        }
        
        /* 进入动画样式 */
        .loading-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10000;
            transition: opacity 0.8s ease, visibility 0.8s ease;
        }
        
        .loading-overlay.hidden {
            opacity: 0;
            visibility: hidden;
        }
        
        .loading-content {
            text-align: center;
            color: white;
            animation: loadingPulse 2s infinite ease-in-out;
        }
        
        .loading-logo {
            font-size: 4rem;
            margin-bottom: 1rem;
            animation: logoSpin 3s linear infinite;
        }
        
        .loading-text {
            font-size: 1.5rem;
            font-weight: 300;
            margin-bottom: 2rem;
            opacity: 0.9;
        }
        
        .loading-spinner {
            width: 60px;
            height: 60px;
            border: 4px solid rgba(255, 255, 255, 0.3);
            border-top: 4px solid white;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto;
        }
        
        .loading-dots {
            display: flex;
            justify-content: center;
            margin-top: 1rem;
        }
        
        .loading-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: white;
            margin: 0 4px;
            animation: dotBounce 1.4s infinite ease-in-out both;
        }
        
        .loading-dot:nth-child(1) { animation-delay: -0.32s; }
        .loading-dot:nth-child(2) { animation-delay: -0.16s; }
        .loading-dot:nth-child(3) { animation-delay: 0s; }
        
        @keyframes loadingPulse {
            0%, 100% {
                transform: scale(1);
                opacity: 1;
            }
            50% {
                transform: scale(1.05);
                opacity: 0.8;
            }
        }
        
        @keyframes logoSpin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        @keyframes dotBounce {
            0%, 80%, 100% {
                transform: scale(0);
            }
            40% {
                transform: scale(1);
            }
        }
        
        .main-content {
            opacity: 0;
            transform: translateY(20px);
            transition: opacity 0.8s ease, transform 0.8s ease;
        }
        
        .main-content.loaded {
            opacity: 1;
            transform: translateY(0);
        }
    </style>
</head>
<body>
    <div class="loading-overlay" id="loading-overlay">
        <div class="loading-content">
            <div class="loading-logo">
                <i class="bi bi-heart-fill"></i>
            </div>
            <div class="loading-text">Akasha Terminal</div>
            <div class="loading-spinner"></div>
            <div class="loading-dots">
                <div class="loading-dot"></div>
                <div class="loading-dot"></div>
                <div class="loading-dot"></div>
            </div>
        </div>
    </div>
    
    <div class="main-content" id="main-content">
        <div class="floating-hearts" id="floating-hearts"></div>
        
        <div class="sleep-mode" id="sleep-mode">
            <div class="sleep-content">
                <h2><i class="bi bi-moon-stars"></i> 休眠模式</h2>
                <p>WebUI正在休眠中...</p>
                <p>点击任意位置唤醒</p>
            </div>
        </div>
    
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-3 col-lg-2 sidebar p-3">
                <h4 class="text-white mb-4">
                    <i class="bi bi-heart-fill"></i> TRSS Akasha Terminal Plugin
                </h4>
                <nav class="nav flex-column">
                    <a class="nav-link active" href="#" data-section="dashboard">
                        <i class="bi bi-speedometer2"></i> 仪表盘
                    </a>
                    <a class="nav-link" href="#" data-section="mysql">
                        <i class="bi bi-database"></i> MySQL管理
                    </a>
                    <a class="nav-link" href="#" data-section="users">
                        <i class="bi bi-people"></i> 用户管理
                    </a>
                    <a class="nav-link" href="#" data-section="sync">
                        <i class="bi bi-arrow-repeat"></i> 数据同步
                    </a>
                    <a class="nav-link" href="#" data-section="stats">
                        <i class="bi bi-bar-chart"></i> 统计信息
                    </a>
                    <a class="nav-link" href="#" data-section="database">
                        <i class="bi bi-table"></i> 数据库查询
                    </a>
                    <a class="nav-link" href="#" data-section="config">
                        <i class="bi bi-gear"></i> 插件配置
                    </a>
                </nav>
            </div>
            <div class="col-md-9 col-lg-10 p-4">
                <div id="dashboard" class="content-section active">
                    <h2>仪表盘</h2>
                    <div class="row mb-4">
                        <div class="col-md-3">
                            <div class="card stats-card">
                                <div class="card-body text-center">
                                    <h3 id="total-users">-</h3>
                                    <p class="mb-0">总用户数</p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="card stats-card">
                                <div class="card-body text-center">
                                    <h3 id="total-commands">-</h3>
                                    <p class="mb-0">总命令数</p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="card stats-card">
                                <div class="card-body text-center">
                                    <h3 id="success-rate">-</h3>
                                    <p class="mb-0">成功率</p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="card">
                                <div class="card-body text-center">
                                    <div class="d-flex align-items-center justify-content-center">
                                        <span id="mysql-status-indicator" class="status-indicator status-disconnected"></span>
                                        <span id="mysql-status-text">MySQL未连接</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 插件详细信息 -->
                    <div class="row mb-4">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-header d-flex justify-content-between align-items-center">
                                    <h5><i class="bi bi-puzzle"></i> 插件详细信息</h5>
                                    <button id="refresh-plugins" class="btn btn-sm btn-outline-primary">
                                        <i class="bi bi-arrow-clockwise"></i> 刷新
                                    </button>
                                </div>
                                <div class="card-body">
                                    <div class="row" id="plugin-info">
                                        <div class="col-md-4">
                                            <div class="card bg-light">
                                                <div class="card-body text-center">
                                                    <h6>插件总数</h6>
                                                    <h4 id="total-plugins">-</h4>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="card bg-light">
                                                <div class="card-body text-center">
                                                    <h6>平均加载时间</h6>
                                                    <h4 id="avg-load-time">-</h4>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="card bg-light">
                                                <div class="card-body text-center">
                                                    <h6>运行状态</h6>
                                                    <h4 id="plugin-status">-</h4>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="mt-3">
                                        <div class="table-responsive" style="max-height: 300px;">
                                            <table class="table table-striped">
                                                <thead>
                                                    <tr>
                                                        <th>插件名称</th>
                                                        <th>版本</th>
                                                        <th>加载时间</th>
                                                        <th>状态</th>
                                                        <th>描述</th>
                                                    </tr>
                                                </thead>
                                                <tbody id="plugin-list">
                                                    <tr>
                                                        <td colspan="5" class="text-center">加载中...</td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 实时日志显示 -->
                    <div class="row">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-header d-flex justify-content-between align-items-center">
                                    <h5><i class="bi bi-terminal"></i> 实时运行日志</h5>
                                    <div>
                                        <button id="clear-logs" class="btn btn-sm btn-outline-danger me-2">
                                            <i class="bi bi-trash"></i> 清空
                                        </button>
                                        <button id="pause-logs" class="btn btn-sm btn-outline-warning me-2">
                                            <i class="bi bi-pause"></i> 暂停
                                        </button>
                                        <button id="download-logs" class="btn btn-sm btn-outline-success">
                                            <i class="bi bi-download"></i> 下载
                                        </button>
                                    </div>
                                </div>
                                <div class="card-body p-0">
                                    <div id="log-container" style="height: 400px; overflow-y: auto; background: #1e1e1e; color: #fff; font-family: 'Courier New', monospace; font-size: 12px; padding: 15px;">
                                        <div class="log-entry">
                                            <span class="text-muted">[系统]</span> 日志系统已启动，等待日志数据...
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- MySQL管理 -->
                <div id="mysql" class="content-section">
                    <h2>MySQL管理</h2>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="card">
                                <div class="card-header">
                                    <h5>MySQL配置</h5>
                                </div>
                                <div class="card-body">
                                    <form id="mysql-config-form">
                                        <div class="mb-3">
                                            <div class="form-check">
                                                <input class="form-check-input" type="checkbox" id="mysql-enabled">
                                                <label class="form-check-label" for="mysql-enabled">
                                                    启用MySQL存储
                                                </label>
                                            </div>
                                        </div>
                                        <div class="mb-3">
                                            <label for="mysql-host" class="form-label">主机地址</label>
                                            <input type="text" class="form-control" id="mysql-host" value="localhost">
                                        </div>
                                        <div class="mb-3">
                                            <label for="mysql-port" class="form-label">端口</label>
                                            <input type="number" class="form-control" id="mysql-port" value="3306">
                                        </div>
                                        <div class="mb-3">
                                            <label for="mysql-user" class="form-label">用户名</label>
                                            <input type="text" class="form-control" id="mysql-user" value="root">
                                        </div>
                                        <div class="mb-3">
                                            <label for="mysql-password" class="form-label">密码</label>
                                            <input type="password" class="form-control" id="mysql-password">
                                        </div>
                                        <div class="mb-3">
                                            <label for="mysql-database" class="form-label">数据库名</label>
                                            <input type="text" class="form-control" id="mysql-database" value="akasha_terminal">
                                        </div>
                                        <button type="submit" class="btn btn-primary">
                                            <span class="loading spinner-border spinner-border-sm" role="status"></span>
                                            保存配置
                                        </button>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="card">
                                <div class="card-header">
                                    <h5>连接控制</h5>
                                </div>
                                <div class="card-body">
                                    <div class="d-grid gap-2">
                                        <button id="connect-mysql" class="btn btn-success">
                                            <span class="loading spinner-border spinner-border-sm" role="status"></span>
                                            连接MySQL
                                        </button>
                                        <button id="disconnect-mysql" class="btn btn-danger">
                                            <span class="loading spinner-border spinner-border-sm" role="status"></span>
                                            断开连接
                                        </button>
                                        <button id="test-connection" class="btn btn-info">
                                            <span class="loading spinner-border spinner-border-sm" role="status"></span>
                                            测试连接
                                        </button>
                                    </div>
                                    <div class="mt-3">
                                        <h6>连接状态</h6>
                                        <div class="d-flex align-items-center">
                                            <span id="mysql-connection-indicator" class="status-indicator status-disconnected"></span>
                                            <span id="mysql-connection-text">未连接</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 用户管理 -->
                <div id="users" class="content-section">
                    <h2>用户管理</h2>
                    <div class="card">
                        <div class="card-header d-flex justify-content-between align-items-center">
                            <h5>用户列表</h5>
                            <button id="refresh-users" class="btn btn-outline-primary btn-sm">
                                <i class="bi bi-arrow-clockwise"></i> 刷新
                            </button>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-striped" id="users-table">
                                    <thead>
                                        <tr>
                                            <th>用户ID</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                    <!-- 用户数据编辑模态框 -->
                    <div class="modal fade" id="userDataModal" tabindex="-1">
                        <div class="modal-dialog modal-lg">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title">编辑用户数据</h5>
                                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                                </div>
                                <div class="modal-body">
                                    <div class="mb-3">
                                        <label for="data-type-select" class="form-label">数据类型</label>
                                        <select class="form-select" id="data-type-select">
                                            <option value="battle">战斗数据</option>
                                            <option value="home">家园数据</option>
                                            <option value="place">地点数据</option>
                                            <option value="house">房屋数据</option>
                                            <option value="shop">商店数据</option>
                                            <option value="quest">任务数据</option>
                                            <option value="inventory">背包数据</option>
                                        </select>
                                    </div>
                                    <div class="mb-3">
                                        <label for="user-data-editor" class="form-label">数据内容 (JSON格式)</label>
                                        <textarea class="form-control json-editor" id="user-data-editor" rows="15"></textarea>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                                    <button type="button" class="btn btn-primary" id="save-user-data">
                                        <span class="loading spinner-border spinner-border-sm" role="status"></span>
                                        保存
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 数据同步 -->
                <div id="sync" class="content-section">
                    <h2>数据同步</h2>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="card">
                                <div class="card-header">
                                    <h5>JSON → MySQL</h5>
                                </div>
                                <div class="card-body">
                                    <p>将JSON文件中的数据同步到MySQL数据库</p>
                                    <button id="sync-json-to-mysql" class="btn btn-primary">
                                        <span class="loading spinner-border spinner-border-sm" role="status"></span>
                                        开始同步
                                    </button>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="card">
                                <div class="card-header">
                                    <h5>MySQL → JSON</h5>
                                </div>
                                <div class="card-body">
                                    <p>将MySQL数据库中的数据同步到JSON文件</p>
                                    <button id="sync-mysql-to-json" class="btn btn-primary">
                                        <span class="loading spinner-border spinner-border-sm" role="status"></span>
                                        开始同步
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

               
                <div id="stats" class="content-section">
                    <h2>统计信息【目前暂不可用】</h2>
                    
                    <div class="row mb-4">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-header">
                                    <h5>使用趋势【目前暂不可用】</h5>
                                </div>
                                <div class="card-body">
                                    <canvas id="usage-chart" width="400" height="200"></canvas>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 命令使用统计 -->
                    <div class="card">
                        <div class="card-header d-flex justify-content-between align-items-center">
                            <h5>命令使用统计</h5>
                            <button id="refresh-stats" class="btn btn-outline-primary btn-sm">
                                <i class="bi bi-arrow-clockwise"></i> 刷新
                            </button>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-striped" id="stats-table">
                                    <thead>
                                        <tr>
                                            <th>命令</th>
                                            <th>用户ID</th>
                                            <th>使用次数</th>
                                            <th>成功次数</th>
                                            <th>失败次数</th>
                                            <th>最后使用时间</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <!-- 统计数据将在这里动态加载 -->
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 数据库查询 -->
                <div id="database" class="content-section">
                    <h2>数据库查询</h2>
                    <div class="row">
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-header">
                                    <h5>数据表信息</h5>
                                </div>
                                <div class="card-body">
                                    <div id="tables-info">
                                        <!-- 表信息将在这里动态加载 -->
                                    </div>
                                    <button id="refresh-tables" class="btn btn-outline-primary btn-sm mt-2">
                                        <i class="bi bi-arrow-clockwise"></i> 刷新
                                    </button>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-8">
                            <div class="card">
                                <div class="card-header">
                                    <h5>SQL查询</h5>
                                </div>
                                <div class="card-body">
                                    <div class="mb-3">
                                        <label for="sql-query" class="form-label">SQL语句 (仅支持SELECT查询)</label>
                                        <textarea class="form-control" id="sql-query" rows="4" placeholder="SELECT * FROM user_battle LIMIT 10;"></textarea>
                                    </div>
                                    <button id="execute-query" class="btn btn-primary">
                                        <span class="loading spinner-border spinner-border-sm" role="status"></span>
                                        执行查询
                                    </button>
                                    <div class="mt-3">
                                        <div id="query-results"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 插件配置 -->
                <div id="config" class="content-section">
                    <h2>插件配置</h2>
                    <div class="card">
                        <div class="card-header">
                            <h5>配置文件管理</h5>
                        </div>
                        <div class="card-body">
                            <div class="mb-3">
                                <label for="config-file-select" class="form-label">选择配置文件</label>
                                <select class="form-select" id="config-file-select">
                                    <option value="cfg.js">cfg.js</option>
                                    <option value="cooldown_config.yaml">cooldown_config.yaml</option>
                                </select>
                            </div>
                            <div class="mb-3">
                                <label for="config-editor" class="form-label">配置内容</label>
                                <textarea class="form-control" id="config-editor" rows="20" style="font-family: monospace;"></textarea>
                            </div>
                            <div class="d-flex gap-2">
                                <button id="load-config" class="btn btn-outline-primary">
                                    <span class="loading spinner-border spinner-border-sm" role="status"></span>
                                    加载配置
                                </button>
                                <button id="save-config" class="btn btn-primary">
                                    <span class="loading spinner-border spinner-border-sm" role="status"></span>
                                    保存配置
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Toast 通知 -->
        <div class="toast-container position-fixed bottom-0 end-0 p-3">
            <div id="toast" class="toast" role="alert">
                <div class="toast-header">
                    <strong class="me-auto">通知</strong>
                    <button type="button" class="btn-close" data-bs-dismiss="toast"></button>
                </div>
                <div class="toast-body" id="toast-body">
                    <!-- 通知内容 -->
                </div>
            </div>
        </div>
    </div> 

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
           
            const loadingOverlay = document.getElementById('loading-overlay');
            const mainContent = document.getElementById('main-content');
            
            if (!loadingOverlay || !mainContent) {
                console.error('Loading animation elements not found');
                return;
            }
            
            setTimeout(function() {
                loadingOverlay.classList.add('hidden');
                setTimeout(function() {
                    mainContent.classList.add('loaded');
                }, 100);
                
                setTimeout(function() {
                    loadingOverlay.style.display = 'none';
                }, 800);
            }, 1500); 
        });
    </script>
    <script src="app.js"></script>
</body>
</html>